package cn.kongwg.service.impl;

import cn.kongwg.bean.User;
import cn.kongwg.dao.UserDao;
import cn.kongwg.dao.impl.UserDaoImpl;
import cn.kongwg.service.UserService;

/**
 * @author kongwg
 * @create 2021-01-22 22:12
 */
public class UserServiceImpl implements UserService {

    UserDaoImpl dao = new UserDaoImpl();

    @Override
    public void register(User user) {
        dao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return dao.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existUsername(String username) {
        if (dao.queryUserByUsername(username) == null) {
            return false;
        }
        return true;
    }
}
